<template>
	<!-- 设置时长 -->
	<view class="page-content">
		<!-- 1-已配对 2-未配对  -->
		<view class="page-top">
			<view class="page-top-l">
				<view class="t-tit">{{i18n.recharge.dangqianpedui}}：Suelinan
					<text class="t-model"
						:style="{background:modelType==='1'?'#D70000':'#00CD8B'}">{{modelType==='1'?i18n.recharge.jihuoban:i18n.recharge.tongyongban}}</text>
				</view>
			</view>
			<view class="page-top-r" v-if="modelType==='2'">
				<!-- 1-激活版  2-通用版 -->
				{{i18n.recharge.shijianzhanghu}}：60{{i18n.recharge.time}}<text class="icons icon-gengduo"></text>
			</view>
		
		</view>
		<scroll-view class="page-body" :scroll-top="scrollTop" scroll-y="true" @scrolltolower="loadmore()">
			<view v-if="datalist && datalist.length > 0 ">
				<!-- <shopCar :list="datalist"  @refresh="refresh" class="shopCar"></shopCar> -->
				<block v-for="(item,index) in datalist" :key="index">
					<view class="list-li">
						<view class="list-li-l">
							<image class="list-li-l-img" :src="icon_time"></image>
							<view class="list-li-l-box">
								<view class="list-li-l-t">{{item.time}}{{i18n.recharge.time}} </view>
								<view class="list-li-l-m">¥{{item.money}}{{i18n.recharge.renminbi}}</view>
							</view>
						</view>
						<view class="list-li-r">
							<image class="icon-tb" :src="item.num>0?icon_jianhao_on:icon_jianhao" @click="signCount(item.id)"></image>
							<view class="list-li-r-txt">{{item.num}}</view>
							<image class="icon-tb" :src="icon_jiahao" @click="addCount(item.id)"></image>
						</view>
					</view>
				</block>
			</view>
			<!--无数据-->
			<empty v-else no-full type="noData"></empty>
		</scroll-view>
		<view class="page-foot-pay">
			<view  class="page-foot-l">{{i18n.recharge.heji}}：￥{{talmoney}}</view>
			<view  class="page-foot-r" @click="tohome">{{i18n.recharge.goumai}}</view>
		</view>
	</view>
</template>

<script>
	import {
		getPayTimeLists //获取赛事组别
	} from '@/common/api.js'
	import { mapGetters, mapActions } from "vuex";
	export default {
		components: {},
		data() {
			return {
				scrollTop: 0,
				icon_time:'/static/icon/shijian.png',
				icon_jianhao:'/static/icon/icon-jianhao.png',
				icon_jianhao_on:'/static/icon/icon-jianhao-on.png',
				icon_jiahao:'/static/icon/icon-jiahao.png',
				tp_id:'',
				datalist: [],
				talmoney:0
			}
		},
		computed: {
		  ...mapGetters([
		    "modelType", "pairStatu"
		  ]),
		  i18n() {
		  	return this.$t('message');
		  }
		},
		onShow(){
			// 导航栏多语言
			uni.setNavigationBarTitle({
				title: this.i18n.tabBar.recharge
			});
			this.getdata();
		},
		onLoad(option) {
			console.log(222, option)
			this.tp_id = option.id;
		},
		methods: {
			...mapActions("user", ["setModelType","setPairStatu"]),
			signCount(id){
				if(this.datalist.length>0){
					this.datalist.forEach((item,ind) =>{
						if(item.id===id){
							if(item.num>0){
								item.num--;
							}
						}
					})
					this.total();
				}
			},
			addCount(id){
				if(this.datalist.length>0){
					this.datalist.forEach((item,ind) =>{
						if(item.id===id){
							item.num++;
						}
					})
					this.total();
				}
			},
			total() { //计算总价---只计算选中的；
				this.talmoney = 0;
				for (var i = 0; i < this.datalist.length; i++) {
					this.talmoney += this.datalist[i].money * this.datalist[i].num;
				}
			},
			radioChange(e){
				console.log(333,e.detail)
			},
			getdata(){
				getPayTimeLists().then(res =>{
					console.log(333,res)
					if(res.code === 2000){
						let datalist = res.data;
						datalist.forEach(item =>{
							this.$set(item,'num',0)
						})
						this.datalist = datalist;
					}
				})
			},
			tohome(type){
				console.log(333);
				// 登录成功后跳转的地址
				uni.navigateBack({
				    delta: 2
				});
				
			}
		}
	}
</script>

<style lang="scss">
	.page-foot-pay{
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		height: 98rpx;
		line-height: 98rpx;
		z-index: 99;
		display: flex;
		justify-content: space-between;
		font-size: 36rpx;
		font-weight: bold;
		.page-foot-l{
			flex: 60;
			padding: 0 30rpx;
			background: $uni-bg-box-color;
		}
		.page-foot-r{
			flex: 40;
			background: $uni-but-bg-color;
			text-align: center;
		}
	}
	
	.page-content {
		display: flex;
		flex-direction: column;
		height: calc(100%);
		width: 100vw;
		background: $uni-bg-color;
		color: $font-color-w;
		padding: $page-row-spacing;
	}
	//头部
	.page-top {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 30rpx;
	
		.t-logo {
			width: 239rpx;
			height: 40rpx;
		}
	
		.page-top-l {
			display: flex;
	
			.t-tit {
				font-size: $font-base;
			}
	
			.t-model {
				height: 40rpx;
				border-radius: 20rpx;
				padding: 0 16rpx;
				font-size: 20rpx;
				font-weight: 400;
				line-height: 40rpx;
				margin-left: 16rpx;
			}
		}
	
		.page-top-r {
			font-size: 28rpx;
			font-weight: 400;
			color: $font-color-d;
		}
	
	
	}

	.page-body {
		height: 100%;
		display: flex;
		flex-direction: column;
		.box-button{
			height: 98rpx;
			background: $uni-but-bg-color;
			box-shadow: 0px 2rpx 9rpx rgba(0, 0, 0, 0.44);
			border-radius: 49rpx;
			font-size: 42rpx;
			text-align: center;
			font-weight: 400;
			line-height: 98rpx;
		}

		.list-li {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: $page-row-spacing;
			background: $uni-bg-box-color;
			box-shadow: 0rpx 2rpx 9rpx 0rpx rgba(0, 0, 0, 0.44);
			border-radius: 20rpx;
			margin-bottom: 40rpx;
			color: $font-color-w;
			.list-li-r{
				display: flex;
				align-items: center;
				width: 200rpx;
				.list-li-r-txt{
					font-size: 36rpx;
					font-weight: 500;
					color: $font-color-w;
					width: 95rpx;
					text-align: center;
				}
				.icon-tb{
					width: 44rpx;
					height: 44rpx
				}
			}

			.list-li-l {
				display: flex;
				font-size: 28rpx;
				.list-li-l-img{
					width: 102rpx;
					height:102rpx;
					margin-right: 36rpx;
				}
				.list-li-l-box{
					display: flex;
					flex-direction: column;
					.list-li-l-t {
						font-size: 32rpx;
						font-weight: 400;
						line-height: 56rpx;
						color: $font-color-w;
					}
					.list-li-l-m {
						font-size: 28rpx;
						font-weight: 400;
						lline-height: 56rpx;
						color: $font-color-d;
					}
				}
			}
		}
	}
</style>
